import { _decorator, Component, Label, Node, NodeEventType } from 'cc';
import { aa } from '../frame/FrameCore';
const { ccclass, property } = _decorator;

@ccclass('LocaleCtrl')
export class LocaleCtrl extends Component {
    @property(Label) localeLabel:Label;
    onEnable() {
        this.node.on(NodeEventType.TOUCH_END,this.changeLocale,this);
        this.changeLabel();
    }
    onDisable(){
        this.node.off(NodeEventType.TOUCH_END,this.changeLocale,this);
    }

    changeLocale(){
        aa.locale.locale = (aa.locale.locale == "en")? "zh": "en";
        this.changeLabel();
    }

    changeLabel(){
        this.localeLabel.string = (aa.locale.locale == "en")? "zh": "en";
    }

   
}

